package org.esk.dablog.modules;

import org.apache.commons.lang.StringUtils;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * This class used to hold module initialization beans
 * User: esk
 * Date: 11.12.2006
 * Time: 17:07:07
 * $Id:$
 */
public class ModuleFactory {
    private Map modules;


    public ModuleFactory() {
        return;
    }

    public void setModules(Map modules) {
        this.modules = modules;
    }

    /**
     * initializes module
     * @param moduleName
     * @param request
     */
    public void initModule(String moduleName, HttpServletRequest request) {
        initModule(moduleName, StringUtils.EMPTY, request);
    }

    /**
     * initializes module with given variable prefix
     * @param name
     * @param prefix
     * @param request
     */
    public void initModule(String name, String prefix, HttpServletRequest request) {
        Module m = (Module) modules.get(name);
        if(m == null) {
            return;
        }
        m.initialize(name, prefix, request);
    }
}
